<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.w3.org/1999/xhtml" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('健身计划')" />
</head>
<body class="gray-bg">
    <div class="wrapper wrapper-content  animated fadeInRight">
        <div class="row" th:fragment="rows">
            <div class="col-sm-4">
                <div class="ibox">
                    <div class="ibox-content">
                        <h3>任务列表</h3>
                        <p class="small"><i class="fa fa-hand-o-up"></i> 在列表之间拖动任务面板</p>

                        <div class="input-group">
                            <input type="text" placeholder="添加新任务" class="input input-sm form-control">
                            <span class="input-group-btn">
                                        <button type="button" class="btn btn-sm btn-white" onclick="add()" shiro:hasPermission="plan:fitness:add"> <i class="fa fa-plus"></i> 添加</button>
                                </span>
                        </div>

                        <div id="listAll">
                            <ul class="sortable-list connectList agile-list" th:fragment="all">
                                <li th:if="${all != null}" th:each="item : ${all}" class="warning-element">
                                    [[${item.description}]]
                                    <div class="agile-detail">
                                        <p hidden="hidden">[[${item.id}]]</p>
                                        <a href="#" class="pull-right btn btn-xs btn-white">[[${item.status_name}]]</a>
                                        <i class="fa fa-clock-o"></i>
                                        [[${item.ctime}]]
                                    </div>
                                </li>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-sm-4">
                <div class="ibox">
                    <div class="ibox-content">
                        <h3>进行中</h3>
                        <p class="small"><i class="fa fa-hand-o-up"></i> 在列表之间拖动任务面板</p>
                        <div id="listProcessed">
                            <ul class="sortable-list connectList agile-list" th:fragment="processed">
                                <li th:if="${processed != null}" th:each="item : ${processed}" class="warning-element">
                                    [[${item.description}]]
                                    <div class="agile-detail">
                                        <p hidden="hidden">[[${item.id}]]</p>
                                        <a href="#" class="pull-right btn btn-xs btn-white">[[${item.status_name}]]</a>
                                        <i class="fa fa-clock-o"></i>
                                        [[${item.ctime}]]
                                    </div>
                                </li>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-sm-4">
                <div class="ibox">
                    <div class="ibox-content">
                        <h3>已完成</h3>
                        <p class="small"><i class="fa fa-hand-o-up"></i> 在列表之间拖动任务面板</p>
                        <div id="listFinished">
                            <ul class="sortable-list connectList agile-list" th:fragment="finished">
                                <li th:if="${not #lists.isEmpty(finished)}" th:each="item : ${finished}" class="warning-element">
                                    [[${item.description}]]
                                    <div class="agile-detail">
                                        <p hidden="hidden">[[${item.id}]]</p>
                                        <a href="#" class="pull-right btn btn-xs btn-white">[[${item.status_name}]]</a>
                                        <i class="fa fa-clock-o"></i>
                                        [[${item.ctime}]]
                                    </div>
                                </li>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:src="@{/js/jquery-ui-1.10.4.min.js}"></script>
    <script>
	    $(document).ready(function () {
	        $(".sortable-list").sortable({connectWith: ".connectList"}).disableSelection();

	        $(document).on('click', 'a',function(){
	            $.post("/plan/fitness/updateFitnessStatus", {"id":$(this).parent().children("p").html()},
                function(data){
                    if (data) {
                        $.post("/plan/fitness/refreshFitness", {"fragment":"all"},
                        function(data){
                            $("#listAll").html(data);
                        });
                       
                    }
                });

            });
	    });

        function add() {
            var url = "/plan/fitness/add";
            $.modal.open("新增",url);
        }
    </script>
</body>
</html>
